<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>

  <script>
    var request = window.indexedDB.open('test', 1)

    request.onupgradeneeded = function (event) {
      var db = event.target.result
      var objectStore = db.createObjectStore('table1', {
        keyPath: 'id',
        autoIncrement: true
      })

      objectStore.createIndex('uid', 'uid', { unique: false })
      objectStore.add({
        uid: 'abcsd',
        age: {
          Cookie: {
            name: 'test',
            val: ''
          },
          setCookie: function (res) {
            console.log("I'm SetCookie" + res)
            this.Cookie.val = res
          },
          getCookie:function(){
            console.log("I got a Cookie:"+this.Cookie.val);
          }
        }
      })
    }

    request.onerror = function (event) {
      alert("Why didn't you allow my web app to use IndexedDB?!")
    }

    request.onsuccess = function(e){
      var db = e.target.result
      var transaction = db.transaction(['table1','readwrite'])
      var obstore = transaction.objectStore('table1')
      var request = obstore.get(1)
    }
  </script>
</html>
